<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <%--<div class="layui-card">--%>
    <%--<div class="layui-form layui-card-header layuiadmin-card-header-auto">--%>

    <%--<div class="layui-form-item">--%>
    <form name="totalForm" id="totalForm" action="${web_domain}/mall/goods/attribute/list" method="get">

        <%--<div class="layui-inline">--%>
        <%--<label class="layui-form-label">规格名称</label>--%>
        <%--<div class="layui-input-inline">--%>
        <%--<input type="text" name="name" placeholder="请输入规格名称" value="<c:if test='${params.name !=null}'>${params.name}</c:if>" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
        <%--</div>--%>

        <%--<div class="layui-inline">--%>
        <%--<button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> 搜索</button>--%>
        <%--</div>--%>
    </form>
    <%--</div>--%>
    <%--</div>--%>

    <%--</div>--%>

    <div class="layui-card">
        <div class="layui-field-box layui-form">
            <%--<a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" id="add"><i class="layui-icon">&#xe61f;</i> 添加</a>--%>

            <table class="layui-table" lay-size="sm">
                <thead>
                <th width="5%"><input id="checkboxs" type="checkbox" value="${item.id}" lay-ignore lay-skin="primary"/></th>
                <%--<th>序号</th>--%>
                <th><fmt:message key='ggmc'/></th>
                <th><fmt:message key='ggms'/></th>
                <th><fmt:message key='ggsx'/></th>
                </thead>
                <c:forEach items="${attributes}" var="item" varStatus="status">
                    <tr>
                        <td><input type="checkbox" value="${item.id}" class="feijin-check" lay-ignore lay-skin="primary"/></td>
                            <%--<td>${status.index + 1 }</td>--%>
                        <td>${item.name }</td>
                        <td>${item.note }</td>
                        <td><c:forEach items="${item.attributes}" var="i"> [ ${i.name} ] </c:forEach></td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>

</div>

<div style="display:none" id="submit">

</div>

<script>

    $(function () {

        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });

        $("#submit").click(function () {
            var ids = [];

            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            var data = ids.join(";");

            $.ajax({
                url: "${web_domain}/mall/goods/attribute/channel/relevancy",
                type: "post",
                dataType: "json",
                data: {
                    "ids": data,
                    "id": "${attributeChannel.id}"
                },
                success: function (result) {
                    if (result.status) {
                        window.parent.location.reload();
                    }
                }
            });

        });

    });
</script>
</body>
</fmt:bundle>
</html>
